let url = location.href
//http://127.0.0.1:5500/PandaOptimization/src/pages/shopdetails.html?id=40769144
let index = url.indexOf('=')
let id = url.substring(index+1) 

$('nav p').click(function(){
    location.href='../pages/index.html'
})


function shopping(){
    $.ajax({
        type: "get",
        url: "http://www.xiongmaoyouxuan.com/api/detail",
        data: {
            id
        },
        success: function (data) {
            let shoppingList = data.data.detail
            console.log(shoppingList)
            let text=''
                text = text+`
                <div class="content">
                <div class="shopimg"><img src="${shoppingList.thumbnail}"></div>
                <div class="shop-content">
                    <h3>
                        <img src="../static/image/shoplogo.png">
                        <span>${shoppingList.title}</span>
                    </h3>
                    <div class="price">
                        <p class="originalprice">原价￥${shoppingList.originPrice}</p>
                        <div>
                            <p>
                                <span>券后价: ¥${shoppingList.price}</span>
                                <span>${shoppingList.couponValue}</span>
                            </p>
                            <span class="buy-person">${shoppingList.saleNum}人已买</span>
                        </div>
                    </div>
                    <div class="buybtn">
                        <p>优惠有效期：${shoppingList.expireDate}</p>
                        <div>领券购买</div>
                    </div>
                </div>
                </div>`;
             $('main').html(text) 
             $('.buybtn div').click(function(){
                location.href='https://uland.taobao.com/coupon/edetail?e=2Jz0n%2BZA9cmlhHvvyUNXZfh8CuWt5YH5OVuOuRD5gLJMmdsrkidbOcgNAa9X6T79uG1ZaNECU%2FS7pVXmA6bTuP9L%2BhhOpd0JXRuv7xpz1L7QEUCpE4O7XadIO5t6JpjEV1g%2FIOEUNHD4xTDPFiVIofzOZOK3S9EBMh%2FknRnwXZ%2BNxsXY%2FXi3AjuKwShCSfyDZV8xdSv5eDcemBPN26lc3uw9Frl%2FS%2FmsuqlSC82SPkMDJKdHsEKr4o6fC%2FNDcd7WTmR4x5CnEU613%2BL5hoPgg%2F865raRWOux&traceId=2132aabb16257115171852014e192e&&union_lens=lensId:TAPI@1625711517@0bb57573_0857_17a83f51e1c_083e@01;linkRuleId:1&nowake=1'
            })  
        }
    });
}
shopping()

